Add new regions
az cosmosdb update --name '<account-name>' --resource-group '<resource-group>' --locations regionName='eastus' failoverPriority=0 isZoneRedundant=False --locations regionName='westus2' failoverPriority=1 isZoneRedundant=False --locations regionName='centralus' failoverPriority=2 isZoneRedundant=False
Enable automatic failovers:
az cosmosdb update \ --name '<account-name>' \ --resource-group '<resource-group>' \ --enable-automatic-failover 'true'
Failover priority switch:
az cosmosdb failover-priority-change \ --name '<account-name>' \ --resource-group '<resource-group>' \ --failover-policies 'eastus=0' 'centralus=1' 'westus2=2'
Manual trigger failover :
- Any priority change to a region that is != 0 will not trigger a failover
az cosmosdb failover-priority-change \ --name '<account-name>' \ --resource-group '<resource-group>' \ --failover-policies 'eastus=0' 'centralus=1' 'westus2=2'
Enable multi-region write:
az cosmosdb update \ --name '<account-name>' \ --resource-group '<resource-group>' \ --enable-multiple-write-locations 'true'
Add custom index policies:
az cosmosdb sql container create \ --account-name '<account-name>' \ --resource-group '<resource-group>' \ --database-name '<database-name>' \ --name '<container-name>' \ --partition-key-path '<partition-key-path-string>' \ --idx '@.\policy.json' \ --throughput '400'
(raw json)
az cosmosdb sql container create \ --account-name '<account-name>' \ --resource-group '<resource-group>' \ --database-name '<database-name>' \ --name '<container-name>' \ --partition-key-path '<partition-key-path-string>' \ --idx '{\"indexingMode\":\"consistent\",\"automatic\":true,\"includedPaths\":[{\"path\":\"/*\"}],\"excludedPaths\":[{\"path\":\"/headquarters/*\"},{\"path\":\"/\\\"_etag\\\"/?\"}]}' \ --throughput '400'
Create new resources
- Account
az cosmosdb create \ --name '<account-name>' \ --resource-group '<resource-group>' \ --default-consistency-level 'strong' \ --enable-free-tier 'true'
--locations regionName='eastus'
- Database
az cosmosdb sql database create \ --account-name '<account-name>' \ --resource-group '<resource-group>' \ --name '<database-name>'
- Container
az cosmosdb sql container create \ --account-name '<account-name>' \ --resource-group '<resource-group>' \ --database-name '<database-name>' \ --name '<container-name>' \ --throughput '400' \ --partition-key-path '<partition-key-path-string>'
- Container level throughput updates
az cosmosdb sql container throughput update --account-name '<account-name>' --resource-group '<resource-group>' --database-name '<database-name>' --name '<container-name>' --throughput '1000'
- Throughput migration
az cosmosdb sql container throughput migrate --account-name '<account-name>' --resource-group '<resource-group>' --database-name '<database-name>' --name '<container-name>' --throughput-type 'manual'